<template>
    <Modal v-model="modal" :title="title" footer-hide :width="90">
        <Table :columns="columns" :data="data" :loading="loading">
            <template slot-scope="{ row }" slot="conver_rate">
                {{typeof(row.conver_rate) == 'number'?`${row.conver_rate}%`:row.conver_rate===''?'/':row.conver_rate}}
            </template>
        </Table>
    </Modal>
</template>

<script>
    import { netreportcompareproject } from '@/api/hqapi';
    export default {
        name: 'compare',
        data() {
            return {
                modal: false,
                title: '',
                data: [],
                loading: false,
                columns: [
                    { title: '年月', key: 'ym', minWidth: 100, fixed: 'left' },
                    { title: '到诊', key: 'arrived_num', minWidth: 100 },
                    { title: '确诊对话', key: 'qz_dialogue_num', minWidth: 100 },
                    { title: '对话', key: 'dialogue_num', minWidth: 100 },
                    { title: '转化率', slot: 'conver_rate', minWidth: 100 },
                    { title: '消费', key: 'plan_consume', minWidth: 150 },
                    { title: '到诊成本', key: 'arrived_cost', minWidth: 150 },
                    { title: '确诊对话成本', key: 'qz_dialogue_cost', minWidth: 150 },
                    { title: '对话成本', key: 'dialogue_cost', minWidth: 150 }
                ]
            };
        },
        methods: {
            initial(params, name, channel) {
                // this.title = `${name}往年${this.$Date(params.month).format('MM')}月份${channel ? `${channel}渠道` : ''}数据同比`;
                this.title = `${name}往年${this.$Date(params.start_time).format('MM-DD')}~${this.$Date(params.end_time).format('MM-DD')}${channel ? `${channel}渠道` : ''}数据同比`;
                this.loading = true;
                netreportcompareproject(params).then(res => {
                    this.data = res;
                    this.modal = true;
                    this.loading = false;
                });
            }
        }
    };
</script>

<style lang="scss" scoped>

</style>
